package comlibs.huydung
{
	import mx.core.UIComponent;
	
	public class Utils
	{
		
		public static function friendlyDateString(days:Number):String{
			if( days < 7 * 6){
				return days + ' days';
			}else if( days < 30 * 5 ){
				var w:Number =  Math.floor(days / 7);
				var d:Number = days % 7;
				return w + " weeks" + (d == 0 ? "" : " " + d + " days");
			}else if( days < 30 * 12 * 2 ){
				var m:Number = Math.floor(days / 30); 
				var d:Number = days % 30;
				return m + " months" + (d == 0 ? "" : " " + d + " days");
			}else{
				var y:Number = Math.floor(days / 365);
				var d:Number = days % 365;
				return y + " years" + (d == 0 ? "" : " " + d + " days");
			}
			return "";
		}
	}
	
	
}